import 'package:fish_redux/fish_redux.dart';
import 'action.dart';
import 'state.dart';
import '../../../app_files.dart';
import 'package:flutter/services.dart';

Effect<OrderResultEditState> buildEffect() {
  return combineEffects(<Object, Effect<OrderResultEditState>>{
    OrderResultEditAction.action: _onAction,
    OrderResultEditAction.onSubmit: _onSubmit,
  });
}

void _onAction(Action action, Context<OrderResultEditState> ctx) {
}

void _onSubmit(Action action, Context<OrderResultEditState> ctx) async {
  List<String> orderInfo = [
    '客户姓名：${ctx.state.model.userName}',
    '客户地址：${ctx.state.model.userAddress}',
    '联系方式：${ctx.state.model.phone}',
  ];
  String resultRes = orderInfo.join('\r\n') + '\r\n' + ctx.state.textEditingController.text;
  await Clipboard.setData(ClipboardData(text: resultRes));
  CommonUtils.showToast(ctx.context,'已复制到剪切板');
}
